package buaa.com.crazzyguess;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import buaa.com.util.Globals;

public class WelcomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        Thread thread = new Thread(){
            @Override
            public void run() {
                Globals.init(WelcomeActivity.this);
                SharedPreferences s = getSharedPreferences("game",MODE_PRIVATE);
                if(s.getInt("nowStage",0)==0){
                    SharedPreferences.Editor editor = s.edit();
                    editor.putInt("nowStage",1);
                    editor.putInt("coin",50);
                    editor.commit();
                }
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Intent intent = new Intent(WelcomeActivity.this,MainActivity.class);
                startActivity(intent);
                finish();
            }
        };
        thread.start();
    }
}
